package kr.saeildamil.androidstudy.ch19;

import kr.saeildamil.androidstudy.R;
import kr.saeildamil.androidstudy.ch19.TreadTest.BackThread;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class RunableTest extends Activity {
	int mMainValue = 0;
	int mBackValue = 0;
	TextView mMain;
	TextView mBack;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch19_threadtest);
		
		mMain = (TextView)findViewById(R.id.ch19_threadtest_mainvalue);
		mBack = (TextView)findViewById(R.id.ch19_threadtest_backvalue);
		
		Thread thread = new Thread(new Runnable() {
			
			@Override
			public void run() {
				while(true){
					while(true){
						mBackValue++;
						try {
							Thread.sleep(1000);
							//mBack.setText("BackValue: " + mBackValue);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					}
				}
				
			}
		});
		thread.start();
	}//end of oncreate
	
	public void mOnClick(View v){
		mMainValue++;
		mMain.setText("MainValue: " + mMainValue);
		mBack.setText("BackValue: " + mBackValue);
	}//end of mOnClick
}
